﻿using AppFx.BizTalk.Diagnostics;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace AppFx.BizTalk.Orchestrations
{
    [Serializable]
    public abstract class OrchestrationHelperBase
    {
        private static readonly ILog Log = LogFactory.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);


        #region Logging Helper Methods
        public static void LogOrchestrationStarting()
        {
            Log.DebugFormat("Orchestration Starting: Name= {0}, Instance={1}", CurrentOrchestration.Name, CurrentOrchestration.InstanceId);
        }

        public static void LogOrchestrationEnd()
        {
            Log.DebugFormat("Orchestration Ending: Name= {0}, Instance={1}", CurrentOrchestration.Name, CurrentOrchestration.InstanceId);
        }

        public static void LogDebug(string message)
        {
            Log.DebugFormat("Message= {0}, Name= {1}, Instance={2}", message, CurrentOrchestration.Name, CurrentOrchestration.InstanceId);
        }

        public static void LogInfo(string message)
        {
            Log.InfoFormat("Message= {0}, Name= {1}, Instance={2}", message, CurrentOrchestration.Name, CurrentOrchestration.InstanceId);
        }

        public static void LogWarn(string message)
        {
            Log.WarnFormat("Message= {0}, Name= {1}, Instance={2}", message, CurrentOrchestration.Name, CurrentOrchestration.InstanceId);
        }

        public static void LogError(string message, Exception ex)
        {
            Log.ErrorFormat("Message= {0}, Name= {1}, Instance={2}, Error={3}", message, CurrentOrchestration.Name, CurrentOrchestration.InstanceId, ex.Message);
            Log.Error(ex);
        }
        #endregion
    }
}
